import java.util.Scanner;
class TreeNode{
    public char val;
    public TreeNode left;
    public TreeNode right;
    public TreeNode(char val){
        this.val=val;
    }
}
public class Test {
    public static void main1(String[] args) {
        //创建二叉树
        TestBinaryTree testBinaryTree=new TestBinaryTree();
        //根节点
        TestBinaryTree.TreeNode root= testBinaryTree.createTree();
        //前序打印
        testBinaryTree.preOrder(root);
        System.out.println("======================");

        testBinaryTree.inOrder(root);
        System.out.println("======================");
        testBinaryTree.postOrder(root);

        System.out.println("++++++++++++++++++++++++");
        System.out.println(testBinaryTree.size(root));
        System.out.println(testBinaryTree.getLeafNodeCount(root));
        System.out.println("_________________________");

        System.out.println(testBinaryTree.getKLevelNodeCount(root, 4));
        System.out.println("这棵树的高度为"+testBinaryTree.getHeight(root));
        System.out.println(testBinaryTree.find(root,'B'));
        TestBinaryTree testBinaryTree1=new TestBinaryTree();
        TestBinaryTree.TreeNode root2=testBinaryTree1.createTree();
        System.out.println(testBinaryTree.isSameTree(root,root2));

        System.out.println(testBinaryTree.isSymmetric(root));
        testBinaryTree.levelOrder(root);
    }
    public static void inOrder(TreeNode root){
        if(root==null){
            return ;
        }
        inOrder(root.left);
        System.out.print(root.val+" ");
        inOrder(root.right);
    }
    public static int i=0;
    public static TreeNode createTree(String str){
        TreeNode root=null;
        if(str.charAt(i)!='#'){
            root=new TreeNode(str.charAt(i));
            i++;
            root.left=createTree(str);
            root.right=createTree(str);
        }else{
            i++;
        }
        str.charAt(1);
        return root;
    }
    public static void main12(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            i=0;
            String str=in.nextLine();
            TreeNode root=createTree(str);
            inOrder(root);
        }

    }

    public static void main(String[] args) {
        TestBinaryTree testBinaryTree=new TestBinaryTree();
        TestBinaryTree.TreeNode  root=testBinaryTree.createTree();
        //testBinaryTree.preOrder(root);
        testBinaryTree.inorderTraversal(root);
    }



}